package stack;

import linkedlist.SingleNode;

public class LinkedStack {
    private SingleNode m_pTopNode;

    public void push(Object object) {
        SingleNode pNode = new SingleNode();
        pNode.setObjData(object);
        if (this.m_pTopNode == null) {
            this.m_pTopNode = pNode;
        } else {
            pNode.setNodeNext(this.m_pTopNode);
            this.m_pTopNode = pNode;
        }
    }

    public Object pop() {
        if (this.m_pTopNode == null) {
            return null;
        }

        Object objResult = this.m_pTopNode.getObjData();
        this.m_pTopNode = this.m_pTopNode.getNodeNext();

        return objResult;
    }

}
